package com.itheima.wallet.web.Controller;

import com.itheima.wallet.api.AccountServiceApi;
import com.itheima.wallet.vo.PageResult;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("account")
public class AccountController {
    @Reference(version = "1.0.0")
    private AccountServiceApi accountServiceApi;

    @GetMapping("/query/{accountId}")
    public ResponseEntity<PageResult> queryAccount(@PathVariable("accountId") String accountId,@RequestHeader("Authorization") String token){

        PageResult pageResult = this.accountServiceApi.queryAccountInfo(Long.valueOf(accountId), token);
        if (pageResult!=null){
            return ResponseEntity.ok(pageResult);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
